package net.ib.mtalk.ui.buddy.info;

import net.ib.mtalk.R;
import net.ib.mtalk.database.DatabaseContract.ContactTable;
import android.content.Context;
import android.database.Cursor;
import android.support.v4.widget.CursorAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

public class GoContactAdapter extends CursorAdapter {

	private Context mContext;
	private LayoutInflater mInflater;
	
	public GoContactAdapter(Context context, Cursor cursor, int flags) {
		super(context, cursor, flags);
		this.mContext = context;
	}

	@Override
	public View newView(Context context, Cursor cursor, ViewGroup parent) {
		mInflater = LayoutInflater.from(context);
		View v = mInflater.inflate(R.layout.item_array, parent, false);
		ViewHolder holder = new ViewHolder();
		holder.textView = (TextView) v.findViewById(R.id.ia_text);
		
		v.setTag(holder);
		return v;
	}
	
	private static class ViewHolder {
		TextView textView;
	}

	@Override
	public void bindView(View view, Context context, Cursor cursor) {
		ViewHolder holder = (ViewHolder) view.getTag();
		String text = cursor.getString(cursor.getColumnIndex(ContactTable.KEY_CONTACT_NUMBER));
		holder.textView.setText(text);
		
	}
}
